package com.silverbox.waimai.thread;

import com.silverbox.shopper.entity.Shopper;
import com.silverbox.shopper.entity.extend.ShopperAndParent;
import com.silverbox.sweeporder.controller.index.vo.ShopperVO;
import com.silverbox.waimai.dubboApi.order.WaimaiServiceApi;
import com.silverbox.waimai.entity.Waimai;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;

/**
 * <pre>
 * 功    能:
 * 涉及版本:
 * 创 建 者: YangYangjun
 * 日    期: 2020-07-01 10:31
 * </pre>
 */
public class SendServiceWindowMsgThread implements Runnable {

    private final static Logger logger = LoggerFactory.getLogger(SendServiceWindowMsgThread.class);

    private ShopperAndParent shopper;
    private Waimai waimai;
    private String sweepUrl;
    private String serviceWindowUrl;

    public SendServiceWindowMsgThread(ShopperAndParent shopper, Waimai waimai, String sweepUrl, String serviceWindowUrl) {
        this.shopper = shopper;
        this.waimai = waimai;
        this.sweepUrl = sweepUrl;
        this.serviceWindowUrl = serviceWindowUrl;
    }

    private WaimaiServiceApi waimaiServiceApi;

    @Override
    public void run() {
        // 生活号结账通知
        ShopperVO shopperVO = new ShopperVO();
        if (shopper != null) {
            BeanUtils.copyProperties(shopper, shopperVO);
            shopperVO.setParentId(shopper.getParentId());
            if (shopper.getParentInfo() != null) {
                shopperVO.setParentNick(shopper.getParentInfo().getNick());
                shopperVO.setParentMinLogo(shopper.getParentInfo().getMinLogo());
            }
        }
        waimaiServiceApi.sendServiceWindowMsg(waimai, shopper.getAlipayUserId(), shopper.getNick(), shopper.getAddress(), sweepUrl, serviceWindowUrl, "3");
    }
}
